/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package merlion.frm.ccm.entity;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;

/**
 *
 * @author Yuwei and Zhiqi
 */
@Entity
public class CreditGroup implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    private Integer extensionDays;
    private String creditGroupTitle;
    private Double creditLimitForWs;
    private Double creditLimitForDs;
    private Double upgradeLimitForWs;
    private Double upgradeLimitForDs;
  
    @OneToMany (targetEntity=CreditAccount.class, cascade={CascadeType.ALL}, fetch=FetchType.EAGER)
    private Collection<CreditAccount> creditAccounts = new ArrayList<CreditAccount>();
    
    public CreditGroup(){
        creditGroupTitle = "";
        creditLimitForDs = (double)0;
        creditLimitForWs = (double)0;
        extensionDays = 0;
        upgradeLimitForDs = (double)0;
        upgradeLimitForWs = (double)0;
    }
    
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Collection<CreditAccount> getCreditAccounts() {
        return creditAccounts;
    }

    public void setCreditAccounts(Collection<CreditAccount> creditAccounts) {
        this.creditAccounts = creditAccounts;
    }

    public String getCreditGroupTitle() {
        return creditGroupTitle;
    }

    public void setCreditGroupTitle(String creditGroupTitle) {
        this.creditGroupTitle = creditGroupTitle;
    }

    public Double getCreditLimitForDs() {
        return creditLimitForDs;
    }

    public void setCreditLimitForDs(Double creditLimitForDs) {
        this.creditLimitForDs = creditLimitForDs;
    }

    public Double getCreditLimitForWs() {
        return creditLimitForWs;
    }

    public void setCreditLimitForWs(Double creditLimitForWs) {
        this.creditLimitForWs = creditLimitForWs;
    }

    public Integer getExtensionDays() {
        return extensionDays;
    }

    public void setExtensionDays(Integer extensionDays) {
        this.extensionDays = extensionDays;
    }

    public Double getUpgradeLimitForDs() {
        return upgradeLimitForDs;
    }

    public void setUpgradeLimitForDs(Double upgradeLimitForDs) {
        this.upgradeLimitForDs = upgradeLimitForDs;
    }

    public Double getUpgradeLimitForWs() {
        return upgradeLimitForWs;
    }

    public void setUpgradeLimitForWs(Double upgradeLimitForWs) {
        this.upgradeLimitForWs = upgradeLimitForWs;
    }
    

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        if (!(object instanceof CreditGroup)) {
            return false;
        }
        CreditGroup other = (CreditGroup) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "merlion.frm.ccm.entity.CreditGroup[ id=" + id + " ]";
    }
    
}
